from abc import ABC, abstractmethod
from typing import List, Optional, Any

from ..agent_types import MemoryRecord # Use the defined schema

class BaseMemory(ABC):
    """Abstract base class for agent memory systems."""

    @abstractmethod
    async def add_record(self, record: MemoryRecord, task_id: Optional[str] = None) -> None:
        """Adds a single record to memory."""
        pass

    @abstractmethod
    async def add_records(self, records: List[MemoryRecord], task_id: Optional[str] = None) -> None:
        """Adds multiple records to memory."""
        pass

    @abstractmethod
    async def retrieve_relevant_records(
        self,
        query: str,
        task_id: Optional[str] = None,
        limit: int = 10,
        filter_criteria: Optional[dict] = None
    ) -> List[MemoryRecord]:
        """Retrieves records relevant to a query, potentially filtered."""
        pass

    @abstractmethod
    async def get_recent_records(
        self,
        task_id: Optional[str] = None,
        limit: int = 10,
        record_type: Optional[str] = None
    ) -> List[MemoryRecord]:
        """Gets the most recent records, optionally filtered by type."""
        pass

    @abstractmethod
    async def clear_task_memory(self, task_id: str) -> None:
        """Removes memory records associated with a specific task (optional)."""
        pass

    @abstractmethod
    async def clear_all_memory(self) -> None:
        """Clears all records from this memory module."""
        pass